<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Title</title>
	<style>
		button {
			background-color: #9f86e5;
			color: #fff;
			padding: 10px 20px;
			border: none;
			border-radius: 5px;
		}
		
		button:active {
			outline-offset: 1px;
			outline: #efe6ff solid 2px;
			background-color: #c7b4fd;
		}
	</style>
</head>
<body>
	<button onclick="handleClick()">提交JSON数据</button>
	<script>
		async function handleClick() {
			const headers = new Headers()
			headers.append('content-type', 'application/json')
			const response = await fetch('http://hmajax.itheima.net/api/register', {
				method: 'POST',
				headers,
				body: JSON.stringify({
					username: 'ningche123',
					password: '123456'
				})
			})
			const result = await response.json()
			alert(result?.message)
		}
	</script>
</body>
</html>